<%-- 
    Document   : status
    Created on : Mar 22, 2013, 4:30:28 AM
    Author     : shou1dwe
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList,java.util.Date, java.text.SimpleDateFormat, com.esdc.librarysystem.datastate.BookState, com.esdc.librarysystem.datastate.ReservationState"%>
<%@include file="utility.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>红星星图书馆 - My Status</title>
        <style>
            body{font-family: monospace;}
p.formheader {padding-left:20px;}
span.bookid {display: inline-block;width:100px;}
span.booktitle {display: inline-block;width:100px;}
span.bookdue {display: inline-block;width:250px;}
span.reservationid {display: inline-block;width:100px;}
span.reservationtitle {display: inline-block;width:100px;}
span.reservationdate {display: inline-block;width:250px;}
        </style>
    </head>
    <body style="font-family: monospace;">
        <%-- <%session.setAttribute("login", request.getParameter("memberId"));%>--%>
        <h1>Search Book:</h1>
        <hr />
        <form action="Results" method="post">
            <p><input type="text" name="keyword"/>
                <select name="category">
                    <option value="title">by Title</option>
                    <option value="author">by Author</option>
                </select>
                <input type="submit" value="Search"></p>
        </form>
        <h1>My Loans:</h1>
        <form action="Status" method="POST">
            <p class="formheader"> 
                <span class="bookid">ID</span>
                <span class="booktitle">TITLE</span>
                <span class="bookdue">DUE DATE</span>
            </p>
            <%
                ArrayList<BookState> loans = (ArrayList<BookState>) request.getAttribute("loans");
                for (BookState book : loans) {
            %>
            <p><input type="checkbox" name="loan" value="<%=book.getId()%>" />
                <span class="bookid"><%=book.getId()%></span>
                <span class="booktitle"><%=book.getTitle()%></span>
                <span class="bookdue"><%=formatDate(book.getDueDate())%></span>
            </p>
            <%
                }
            %>
            <input type="submit" value="Renew Selected">
        </form>

        <h1>My Rervations:</h1>

        <form action="Status" method="POST">
            <p class="formheader">
                <span class="reservationid">ID</span>
                <span class="reservationtitle">TITLE</span>
                <span class="reservationdate">RESERVED ON</span>
            </p>
            <%
                ArrayList<ReservationState> reservationStates = (ArrayList<ReservationState>) request.getAttribute("reservations");
                for (ReservationState reservation : reservationStates) {
            %>
            <p><input type="checkbox" name="reservation" value="<%=reservation.getId()%>" />
                <span class="reservationid"><%=reservation.getId()%></span>
                <span class="reservationtitle"><%=reservation.getTitle()%></span>
                <span class="reservationdate"><%=formatDate(reservation.getReserveDate())%></span>
            </p>
            <%
                }
            %>
            <input type="submit" value="Delete Selected">
        </form>
            <p><a href="Logout">Log out</a> </p>
    </body>
</html>